layui.config({
	base : "js/"
}).use(['form','layer'],function(){
	var form = layui.form,
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;
	//video背景
	$(window).resize(function(){
		if($(".video-player").width() > $(window).width()){
			$(".video-player").css({"height":$(window).height(),"width":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}else{
			$(".video-player").css({"width":$(window).width(),"height":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}
	}).resize();
	
	//登录按钮事件
    form.on("submit(login)", function (data) {
        var index = layer.open({
            type: 3,
            content:'登录中...'
        })
        //登录验证
        $.ajax({
            url: '../../api/login',
            type:'post',
            data: {
                loginID: data.field.username,
                password: data.field.password
            },
            datatype: 'json',
            success: function (data) {
                var res = JSON.parse(data)
                console.log(res)
                if (res.success) {
                    layer.msg(res.msg, { time: 1000, icon: 1 }, function () {
                        window.location.href = "../../";
                    });
                } else {
                    layer.msg(res.msg, { time: 1000, icon: 2 });
                }
                layer.close(index);
            },
            fail: function (err) {
                console.log(err)
            }
        });
        return false;
		 
	})
})
